#ifndef OBJECT_H_
#define OBJECT_H_
#include "global.h"
#include "stl-util.h"
#include <vector>
namespace tinyscript{

// The Object is the root of every referenced object inside of script.
// Simply puts it, all the resource inside of the script which the user
// can use , invoke , declare or reference must be an object and it is
// also something that GC work with. An Object is a handler which holds
// the value or type of resource inside of the script. An Object can 
// own a resource. A resource inside of the script is :
// 1) Int
// 2) Float(Double)
// 3) String
// 4) Variable/Symbol
// 5) Null
// 6) List
// 7) Function
// Therefore an object can be any one of these 7 type of resources.

// There are 3 type of referenced object which _NEEDS_ to be hold inside
// of heap memory. This 3 type of object needs GC , no matter it is a
// simple reference count or a real GC. Anyway, we will handle all the
// resource using Handle class which help us to manage resource in a 
// more consistent way.


// A TSString is a representation of a string object that has the
// string value during the code execution. This string object has the
// string value , and the user _MUST_ use handler to access this 
// object on C++ side. The std::string will not be used here since
// the std::string has defualt byte-wide encoding, which is not scaled
// once I want to shift to UNICODE or other encoding type. Same as 
// many other script language, a string is not a mutable object. 

class TSString {
public:
	typedef uint32_t HsahType;
public:
	const char_t* ToAnsi() const;
	const std::vector<char_t> ToStringVector() const;
	HsahType hash_value() const {
		return hash_value_;
	}
	// This reference count is not the reference count of 
	// memory, but the string reference in scripts that
	// points to this string.
	uint32_t reference_count() const;

public:

	TSString( const std::vector<char_t>& str):
	reference_count_(1){
		CopyFrom(str);
	}

	TSString( const char_t* str ):
	reference_count_(1){
		CopyFrom(str);
	}

private:
	void CopyFrom( const std::vector<char_t>& str );
	void CopyFrom( const char_t* str );
private:
	std::vector<char_t> string_;
	uint32_t reference_count_;
    uint32_t hash_value_;
	DISALLOW_COPY_AND_ASSIGN(TSString);
};

// A TSList is the internal representation of a list object
// in script. It provides many interfaces for user to manipulate
// the value , key and some behavior inside of the scripts.

class TSList {
public:
	TSList();
};


}// namespace tinyscript

#endif // OBJECT_H_
